Skip to content

fix(android): don't count the keyboard against maxContentHeight - #1017

Merged
lodev09 merged 5 commits into
lodev09:mainfrom
wildseansy:fix/android-max-content-height-keyboard
Nov 16, 2026
Merged

lodev09 merged 5 commits into
lodev09:mainfrom
wildseansy:fix/android-max-content-height-keyboard

Conversation

@wildseansy

@wildseansy wildseansy commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Android, maxContentHeight capped the sheet's content plus the keyboard. getDetentHeight added the keyboard inset to the detent height and then applied maxContentHeight, so the keyboard used up the cap. When content + keyboard exceeded maxContentHeight, the sheet stopped at the cap and the keyboard covered the bottom of the content, e.g. a submit button below a TextInput in a content-sized (auto) sheet.

iOS caps the content and lifts the sheet above the keyboard, and the docs describe maxContentHeight as "the absolute maximum height of the sheet content". This change does the same on Android: the footer–keyboard overlap and maxContentHeight apply to the content first, then the keyboard is added, still clamped to the screen.

  • With no keyboard, or no maxContentHeight, the result is unchanged.
  • Every caller still clamps the sheet to realScreenHeight - topInset, so a tall sheet stops below the status bar. There, the existing scrollable keyboard inset lets the content scroll above the keyboard, as on iOS.
before: min(content + keyboard - footerOverlap, maxContentHeight, screen)
after:  min(min(content - footerOverlap, maxContentHeight) + keyboard, screen)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

Tested in an app on React Native 0.88 with true-sheet 4.0.1 plus this change, on an Android emulator (Pixel 8, API 36, Gboard). The sheet is a content-sized (auto) sheet with maxContentHeight = 75% of the window, holding a title, a multiline TextInput and a button below it.

  • 1080x2340 at density 480, font scale 1.15: before, the sheet stopped at 75% and the button was under the keyboard; after, the button sits right above the keyboard.
  • Small screen at font scale 1.3 (content + keyboard taller than the screen): the sheet stops below the status bar and the plugged scrollableRef scrolls the button above the keyboard.
  • Keyboard hidden: the sheet returns to its content height. A sheet without an input keeps its height.

Screenshots / Videos

Same sheet, same device (1080x2340, density 480, font scale 1.15), keyboard up:

Before (4.0.1) After (this PR)
Before: the sheet stops at the 75% cap and the keyboard covers the Add button After: the Add button sits above the keyboard

Checklist

  • I tested on iOS (Android-only change)
  • I tested on Android
  • I tested on Web (Android-only change)
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

getDetentHeight added the keyboard inset to the detent height and then
applied maxContentHeight, so the keyboard used up the content cap. A sheet
whose content plus keyboard exceeded maxContentHeight stopped at the cap and
the keyboard covered the bottom of its content, e.g. a submit button below a
text input. iOS caps the content and lifts the sheet above the keyboard.

Cap the content height first, then add the keyboard, still clamped to the
screen. With no keyboard the result is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

@wildseansy is attempting to deploy a commit to the lodev09 Team on Vercel.

A member of the Team first needs to authorize it.

@lodev09

lodev09 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks! I reproduced this on main and verified the fix on Android (Pixel 10 Pro XL, API 37), then compared it with iOS (iPhone 18 Pro Max simulator, iOS 27).

Repro: an auto sheet with maxContentHeight at 75% of the window, a multiline input, and an "Add" button below it.

Case main This PR iOS
Content + keyboard taller than the cap The sheet stops at the cap and the keyboard covers "Add" The sheet rises, "Add" sits above the keyboard The sheet rises, "Add" sits above the keyboard
Content alone taller than the cap The sheet doesn't move when the keyboard opens The sheet rises to the top inset The sheet rises to the top

The new order (footer overlap, then the maxContentHeight cap, then the keyboard, then the screen clamp) matches iOS: autoHeightForKeyboardHeight: subtracts the footer overlap, the detent resolver caps at maxContentHeight, and UIKit lifts the sheet by the keyboard.

I pushed a few commits to your branch:

  • Merged main to resolve the CHANGELOG.md conflict.
  • Collapsed the cap into a single minOf and renamed the local, since contentHeight shadowed the class property.
  • Reworded the changelog entry to also mention that a sheet already at maxContentHeight now rises with the keyboard instead of staying put (the second row above).

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-true-sheet Ready Ready Preview Nov 16, 2026 4:11pm UTC

Request Review

@lodev09
lodev09 merged commit 15cbd26 into lodev09:main Nov 16, 2026
5 checks passed
@wildseansy
wildseansy deleted the fix/android-max-content-height-keyboard branch November 16, 2026 18:37

This branch was successfully deployed

1 active deployment
Preview — af27a14b Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants